<?php
namespace Admin\Controller;
use Think\Controller;
class UtilController extends Controller {
    public function upload(){
    	$upload = new \Think\Upload();// 实例化上传类
	    $upload->maxSize   =     3145728 ;// 设置附件上传大小
	    $upload->exts      =     array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型
	    $upload->rootPath  =      './Public/upload/'; // 设置附件上传根目录
	    // 上传单个文件 
	    $info   =   $upload->uploadOne($_FILES['file']);
	    if(!$info){
	        echo $upload->getError();
	    }else{
	        echo '/Public/upload/'.$info['savepath'].$info['savename'];
	    }
    }
    //使在编辑器中图片可以正常显示和上传
    public function uploadJson(){
    	$upload = new \Think\Upload();// 实例化上传类
	    $upload->maxSize   =     3145728 ;// 设置附件上传大小
	    $upload->exts      =     array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型
	    $upload->rootPath  =      './Public/upload/'; // 设置附件上传根目录
	    // 上传单个文件 
	    $info   =   $upload->uploadOne($_FILES['imgFile']);
	    if(!$info){
	    	$this->ajaxReturn(array('error'=>1,'message'=>$upload->getError()));
	    }else{
	    	$pash='Public/upload/'.$info['savepath'].$info['savename'];
	    	$this->ajaxReturn(array('error'=>0,'url'=>$pash));
	    }
    }
   }